package com.ycg.vue.result;

import lombok.Builder;
import lombok.Data;

/**
 * @Description 统一返回结果
 * @Author jink
 * @Date 2024/1/17
 */
@Data
@Builder
public class Result {
    private Integer code;
    private String msg;
    private Object data;

    public static Result success(Integer code, String msg, Object data) {
        return Result.builder().code(code).msg(msg).data(data).build();
    }

    public static Result success(String msg, Object data) {
        return Result.builder().code(200).msg(msg).data(data).build();
    }

    public static Result success(Object data) {
        return Result.builder().code(200).msg("ok").data(data).build();
    }

    public static Result ok(String msg) {
        return Result.builder().code(200).msg(msg).build();
    }

    public static Result success() {
        return Result.builder().code(200).msg("ok").build();
    }

    public static Result error(String msg) {
        return Result.builder().code(500).msg(msg).build();
    }

    public static Result error(Integer code, String msg) {
        return Result.builder().code(code).msg(msg).build();
    }

}
